
<template>
  <div class="app-container">
    <el-container class="main-container">
        <el-header class="main-header">
            <div class="header-content">
                <el-button type="primary" @click="backLogin" class="logout-btn">
                    <el-icon><ArrowLeft /></el-icon>
                    退出登录
                </el-button>
                <h1 class="system-title">智能餐厅管理系统</h1>
                <div class="header-spacer"></div>
            </div>
        </el-header>
        <el-container class="content-container">
            <el-aside width="220px" class="sidebar">
                <el-menu
                    default-active="1"
                    class="sidebar-menu"
                    @select="handleSelect">
                    <el-menu-item index="1" class="menu-item">
                        <router-link to="/homepage" class="menu-link">
                            <el-icon><House /></el-icon>
                            <span>首页</span>
                        </router-link>
                    </el-menu-item>
                    <el-menu-item index="2" class="menu-item">
                        <router-link to="/employee" class="menu-link">
                            <el-icon><User /></el-icon>
                            <span>员工管理</span>
                        </router-link>
                    </el-menu-item>
                    <el-menu-item index="3" class="menu-item">
                        <router-link to="/category" class="menu-link">
                            <el-icon><Menu /></el-icon>
                            <span>菜品分类</span>
                        </router-link>
                    </el-menu-item>
                    <el-menu-item index="4" class="menu-item">
                        <router-link to="/dish" class="menu-link">
                            <el-icon><Food /></el-icon>
                            <span>菜品管理</span>
                        </router-link>
                    </el-menu-item>
                    <el-menu-item index="5" class="menu-item">
                        <router-link to="/setmeal" class="menu-link">
                            <el-icon><Collection /></el-icon>
                            <span>套餐管理</span>
                        </router-link>
                    </el-menu-item>
                    <el-menu-item index="6" class="menu-item">
                        <router-link to="/user" class="menu-link">
                            <el-icon><Avatar /></el-icon>
                            <span>用户管理</span>
                        </router-link>
                    </el-menu-item>
                </el-menu>
            </el-aside>
            <el-container class="main-content">
                <el-main class="content-main">
                    <router-view></router-view>
                </el-main>
                <el-footer class="main-footer">
                    <div class="footer-content">
                        <span>© 2024 智能餐厅管理系统 - 技术支持</span>
                    </div>
                </el-footer>
            </el-container>
        </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import {
  Check,
  Delete,
  Edit,
  Message,
  Search,
  Star,
  ArrowLeft,
  House,
  User,
  Menu,
  Food,
  Collection,
  Avatar
} from '@element-plus/icons-vue'

import router from '../router';

const backLogin =()=>{
    sessionStorage.removeItem('token')
    router.push('/login')
}

const handleSelect = (key, keyPath) => {
    console.log(key, keyPath)
}
</script>

<style scoped>
.app-container {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.main-container {
  height: 100%;
}

.main-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: relative;
  z-index: 1000;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}

.logout-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}

.system-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header-spacer {
  width: 120px; /* 与logout-btn宽度保持一致 */
}

.content-container {
  height: calc(100vh - 60px);
}

.sidebar {
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-menu {
  border: none;
  background: transparent;
  padding-top: 20px;
}

.menu-item {
  margin: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.menu-item:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateX(4px);
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 12px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.menu-link:hover {
  color: inherit;
}

.menu-link .el-icon {
  font-size: 18px;
}

.main-content {
  background: #f5f7fa;
}

.content-main {
  background: white;
  margin: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  padding: 24px;
  overflow-y: auto;
  min-height: calc(100vh - 140px);
}

.main-footer {
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
}

.footer-content {
  color: #6c757d;
  font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    width: 180px !important;
  }
  
  .header-content {
    padding: 0 12px;
  }
  
  .system-title {
    font-size: 20px;
  }
  
  .content-main {
    margin: 8px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 160px !important;
  }
  
  .system-title {
    font-size: 18px;
  }
  
  .logout-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
}
</style>
